﻿using System;
using System.Collections.Generic;
using System.Text;

namespace Cache.Services.Interface
{
    /// <summary>
    /// 缓存接口
    /// </summary>
    public abstract class ICacheContext
    {
        /// <summary>
        /// 是否存在此缓存
        /// </summary>
        /// <param name="key"></param>
        /// <returns></returns>
        public abstract bool Exists(string key);
        /// <summary>
        /// 取得缓存数据
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="key"></param>
        /// <returns></returns>
        public abstract T GetCache<T>(string key) where T : class;
        /// <summary>
        /// 设置缓存
        /// </summary>
        /// <param name="key"></param>
        /// <param name="value"></param>
        /// <param name="expire"></param>
        public abstract bool SetCache<T>(string key, T value, DateTime expire);
        /// <summary>
        /// 移除缓存
        /// </summary>
        /// <param name="key"></param>
        public abstract bool RemoveCache(string key);
        /// <summary>
        /// 重命名Key
        /// </summary>
        /// <param name="key"></param>
        /// <param name="newKey"></param>
        /// <returns></returns>
        public abstract bool RenameKey(string key, string newKey);

    }
}
